#ifndef _MODULE_BOSS
#define _MODULE_BOSS
#include "page.module.js"
#include "prefs.module.js"
#include "console.module.js"
#include "task.lib.js"
#include "ajax.lib.js"
#include "utility.lib.js"
#include "usolib.lib.js"

var Boss = {
	cash: 0,
	cash_str: '$0',
	stamina: 0,
	stamina_total: 0,
	energy: [0, 0],
	health: 1,
	exp_points: 0,
	ignore: [],
	update: function(html) {
		if (m = html.match(/<span id="app8743457343_cur_cash" fbcontext=".*?">(.*?)<\/span>/)) {
			Boss.cash_str = m[1];
			Boss.cash = Utility.make_number(Boss.cash_str);
		}
		if (m = html.match(new RegExp('<span id="app8743457343_cur_health" fbcontext=".*?">(.*?)</span>/([0-9]*)'))) {
			Boss.health = parseInt(m[1], 0) / parseInt(m[2], 0);
		}
		if (m = html.match(new RegExp('<span id="app8743457343_cur_energy" fbcontext=".*?">(.*?)</span>/([0-9]*)'))) {
			Boss.energy = [parseInt(m[1], 0), parseInt(m[2], 0)];
		}
		if (m = html.match(new RegExp('<span id="app8743457343_cur_recovery" fbcontext=".*?">(.*?)</span>/([0-9]*)'))) {
			Boss.stamina = parseInt(m[1], 0);
			Boss.stamina_total = parseInt(m[2], 0);
		}
		if ( new RegExp('>Level Up.*?</a>').test( html ) && Settings.level ) {
			Ajax(Page.domain + '/mobwars/profile/', function(xhr) {
				if (Page.pausing)
					return;
				Task.level(xhr.responseText);
			});
		}
		Console.update_stats();
	}
};
#endif
